package com.db.springsource;

import com.db.springsource.operation.OperationAdd;
import com.db.springsource.operation.Operation;
import com.db.springsource.writer.ResultWriter;
import com.db.springsource.writer.ScreenWriter;

public class Calculate {
    private Operation operation = new OperationAdd();
    private ResultWriter resultWriter = new ScreenWriter();

    public void setOperation(Operation operation) {
        this.operation = operation;
    }

    public void setResultWriter(ResultWriter resultWriter) {
        this.resultWriter = resultWriter;
    }

    public void execute(String[] args) {
        long op1 = Long.parseLong(args[0]);
        long op2 = Long.parseLong(args[1]);
        resultWriter.showResult("The result of " + op1 + operation.getOperationName() + op2 + " is " + operation.operate(op1, op2));
    }
}
